package com.bdqn.bookshop.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bdqn.bookshop.entity.Books;
import com.bdqn.bookshop.utils.ClassifyParentAndChild;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BooksMapper extends BaseMapper<Books> {

    @Select("select *,(select nick_name from mall_user WHERE  id = b.publisher) publisherName,(select nick_name from mall_user WHERE  id = b.purchaser)purchaserName from books b where id = #{id} ")
     Books selectBookById(Integer id);

    @Select("select  (SELECT cl.classify_name from classify cl where id = c.parent_id) parentName , c.classify_name childName from classify c where id in (${classifyId})")
    List<ClassifyParentAndChild> selectParentAndChildByBookClassify(String classifyId);
}
